home *** CD-ROM | disk | FTP | other *** search
/ HPAVC / HPAVC CD-ROM.iso / BLACDEMO.ZIP / scrdemo3.inc < prev    next >
Text File  |  1995-05-29  |  23KB  |  979 lines

  1. ;*** Scrolly part of demo
  2. .data
  3.  
  4. TestX        dw    0
  5.  
  6. Gravity     EQU    1
  7. Floor        EQU    430
  8. PAGE2        EQU    32320
  9.  
  10. ScrollyMsg    LABEL BYTE ; ^ =short delay, & = longer delay
  11. DB "CALL  BLACK ICE& GUERNSEY'S   HOTTEST  ^ BBS...  OVER 2GB OF FILES"
  12. DB " PLUS CD'S ROTATED!  DUAL 28K8 NODES... 0148139633& 0148135323& "
  13. DB "OVER 200 ECHOMAIL AREAS FROM  FIDONET  ^ AND  MERCURY ^  INTERNET E-MAIL"
  14. DB "   BLACKICE.CONQUEROR.CO.UK   EURO DIST SITE FOR LORE & ENVY TECHNOLOGY"
  15. DB " RELEASES....  BACK TO SINBAD....CHEERS FOR THE INTRO DAMIEN.... "
  16. DB "..BIG THANKS FROM THE AUTHOR GO OUT TO VARIOUS GURUS...MIKE ABRASH"
  17. DB "....DRAEDEN.....LITHIUM......TRAN.....ID SOFTWARE..FUTURE CREW."
  18. DB "...BULLFROG....PLUS GREETS TO FRONTMAN.....TA FOR YOUR GREET M8!!...SCUBED...DENTHOR....WISHBONE AND EVERYBODY"
  19. DB " ON BLACK ICE.....AND OF COURSE THANKS TO DAMIEN GUARD FOR SETTING UP THE"
  20. DB "LEADING BBS IN GUERNSEY....THERE IS NO SUBSTITUTE!! WHERE BLACK ICE GOES.."
  21. DB "THE REST FOLLOW....."
  22. DB "...ARE YOU REALLY STILL READING THIS? OK THEN...IT'S YOUR TIME...SOME "
  23. DB "BACKGROUND ON ME THEN...LEAVE NOW WHILE YOU CAN...BTW I'M JUST WRITING"
  24. DB " THIS AFTER WATCHING 'FIELD OF DREAMS' AGAIN ON T.V...I STILL CAN'T"
  25. DB " WATCH IT WITHOUT BAWLING MY EYES OUT...DAMN....THIS IS THE FIRST DEMO "
  26. DB "I HAVE PRODUCED...NOT INCLUDING A FEW MINOR EFFECT THANGS...SO COMMENTS "
  27. DB "ARE WELCOME! I'VE CODED IN C FOR A WHILE AND MOVED TO ASM ABOUT 8 MONTHS "
  28. DB "AGO.....AT 21 I HAVE SOME RUNNING TO DO TO CATCH UP WITH FUTURE CREW!! "
  29. DB "   I PLAN TO CONCENTRATE ON GAMES DEVELOPMENT FROM NOW ON...BUT I EXPECT "
  30. DB "THERE'LL BE A FEW SNIPPETS TO RELEASE AS DEMOS..  B.T.W. IF YOU WANT THE "
  31. DB "SOURCE CODE TO THIS DEMO IT IS INCLUDED WITH THE ZIP...I BELIEVE STRONGLY "
  32. DB "IN FREE RELEASE OF KNOWLEDGE....ALL YOU CODERS WHO CHARGE SHAREWARE FEES"
  33. DB " FOR THE FULL VERSIONS OF YOUR CODE..SHAME ON YOU!!! I LEARNED A LOT FROM"
  34. DB " OTHER PEOPLE'S RELEASED CODE, AND I INTEND TO RETURN THE FAVOUR...IF YOU "
  35. DB "CAN CALL MY DISORGANISED JUMBLE OF CODE A FAVOUR!! WHICH REMINDS ME...BIG "
  36. DB "THANKS TO FRONTMAN FOR RELEASING HIS EXCELLENT 8 CHANNEL MOD PLAYING "
  37. DB "CODE..EVEN THOUGH I COULDN'T USE IT 'COS TASM 4 DOESN'T LIKE IT...BUT YOU'RE"
  38. DB " THE ONLY PERSON I'VE KNOWN TO RELEASE MOD CODE OF THIS QUALITY FOR FREE."
  39. DB " RESPECT DULY EARNED...YOU'RE A STAR. CREDIT GOES TO FUTURE CREW FOR THE "
  40. DB "4 CHANNEL MOD CODE IN THIS DEMO...EVEN THOUGH IT IS A LITTLE OLD. I PLAN "
  41. DB "TO WRITE MY OWN SOMETIME, IF I EVER GET THE TIME!!"
  42. DB "   SO...YOU'RE STILL HERE? HMM...WHAT NEXT? STRANGELY ENOUGH FOR A DEMO "
  43. DB "CODER I'M NOT FROM THE NETHERLANDS NOR AM I AT UNI. I'M STUDYING A DEGREE "
  44. DB "IN MATHS AND COMPUTER SCIENCE IN MY SPARE TIME THOUGH...HENCE THE LACK OF "
  45. DB "TIME FOR CODING!!    ADVICE TO NEW CODERS...FIRSTLY GET THE EXCELLENT "
  46. DB "'PC GAMES PROGRAMMERS ENCYCLOPEDIA' AVAILABLE ON ANY GOOD BBS...WHEN "
  47. DB "YOU'RE LOOKING FOR TIPS ON REALLY FAST CODE GO OUT AND BUY MIKE ABRASH'S "
  48. DB "'ZEN OF CODE OPTIMIZATION'..I GOT IT AFTER WRITING THIS DEMO AND I'VE "
  49. DB "LEARNT LOADS FROM IT....THIRDLY THE ONLY WAY TO BE A GOOD CODER IS TO "
  50. DB "SPEND LOADS OF TIME CODING. THERE IS NO OTHER WAY. SORRY. "
  51. DB "JEEZ YOU'RE STILL READING THIS CRAP?!? TIME FOR SOME FASCINATING..NOT..FACTS!"
  52. DB "   1. SINBAD IS THE SECOND NAME I'VE HAD..THE OTHER WAS 'WARLOCK'...AND IS "
  53. DB "DUE TO MY INEXPLICABLE LOVE OF ANY OLD FANTASY FILM FEATURING STOP FRAME "
  54. DB "ANIMATION MONSTERS...ESPECIALLY SINBAD FILMS....PLUS IF I HAD THE EARRING"
  55. DB " I RECKON I'D BE A PRETTY GOOD LIKENESS! HEHE..   2. I'M A "
  56. DB "BIG FAN OF SCIENCE FICTION AND FANTASY NOVELS OR T.V. SHOWS...BIG FAVES "
  57. DB "ARE DEEP SPACE 9 AND THE X FILES... 3. I HAVE NO LIFE...HEHE..  4. I "
  58. DB "REALLY AM RUNNING OUT OF THINGS TO SAY NOW.... 5. DON'T YOU HATE IT "
  59. DB "WHEN YOU FIND A BIT OF SHELL IN YOUR EGG SANDWICH?   6. PRINGLES CRISPS "
  60. DB "ARE DEFINITELY IMPREGNATED WITH AN ADDICTIVE CHEMICAL...  7. DOES HEATHER"
  61. DB " LOCKLEAR LIVE IN A DIFFERENT TIME CONTINUUM? 8. WHY THE HELL DON'T I "
  62. DB "SHUT THE !?!?! UP? 9. WHAT'S THE CAPITAL OF INDIA? 10. DID YOU FALL ASLEEP "
  63. DB "AT THE KEYBOARD OR SOMETHING?      THIS IS GONNA REPEAT PRETTY SOON...YOU'D "
  64. DB "BETTER STOP IT OR PUT MASKING TAPE OVER THE SCREEN TO STOP YOUR TIMELINE "
  65. DB "BEING INTERFERED WITH!     ARMADILLOS!!!   FRESH FRUIT!   POINTED STICKS! "
  66. DB "   SOD IT...HERE COME THE WARDENS...GOTTA PACK THIS IN NOW!"
  67. DB "  THANKS FOR READING....YOU MUST BE MORE NUTS THAN I AM....SEEEEEEEEEEEYA!!          $"
  68.  
  69. StartParams LABEL BYTE      ;make a smoother 'wave'                      
  70. dw    0, 400
  71. dw    2, 403
  72. dw    4, 410
  73. dw    6, 421
  74. dw    -7,421 
  75. dw    -5,410
  76. dw    -3,403
  77. dw    -1,400
  78. dw    1, 401
  79. dw    3, 406
  80. dw    5, 415
  81. dw    7, 428
  82. dw    -6,415    
  83. dw    -4,406
  84. dw    -2,401
  85. dw    999
  86.  
  87. MsgPtr        dw    ?        ;pointer to current letter in message
  88. ParamPtr    dw    ?        ;pointer to sprite start parameters
  89. APage        dw    0        ;Active page
  90. Clip        dw    1        ;no of writes to do (for clipping)
  91. DelayCount    dw    0        
  92. Paused        dw    0        ;toggle - cannot use DelayCount as
  93.                     ;that may have changed in the frame
  94.  
  95. Sprite STRUC
  96. CurrentY    dw    0        ;Y momentum
  97. XPos        dw    0        ;literal X value + 40 (to allow clipping)
  98. YPos        dw    0        ;virtual Y value
  99. CurrentPos    dw    0        ;for drawing
  100. OldPos        dw    0        ;for erasing
  101. GFXPtr        dw    0        ;offset of graphics for this letter
  102. MaskPtr        dw    0        ;offset of mask for this letter
  103.     ENDS
  104.  
  105. Letter    Sprite    11 dup ({CurrentY = 0})
  106. DummyMask    db    (32*8) dup (0)    ;for spaces
  107. FarRight    dw    0
  108. FarLeft        dw    0
  109.  
  110. .code
  111.  
  112. SetUpSprites    PROC NEAR
  113.     xor    bx, bx
  114.     mov    cx, 11
  115.     mov    ax, 40            ;equiv to 0 X value on screen
  116.   sloop:
  117.     mov    FS:[Letter[bx].XPos], ax
  118.     mov    FS:[Letter[bx].MaskPtr], offset DummyMask
  119.     sub    ax, 40
  120.     mov    FS:[Letter[bx].OldPos], ax        ;for background restoration
  121.     mov    FS:[Letter[bx].YPos], 400         ;starting Y
  122.     add    ax, 40
  123.     add    ax, 8            ;(8*4 = 32 pix wide)
  124.     add    bx, 14            ;size of struc
  125.     loop    sloop
  126.  
  127.     mov    FS:[FarRight], (10 * 14)    ;make last sprite far-right
  128.     mov    FS:[FarLeft], 0            ;make first sprite far-left
  129.  
  130.     mov    FS:[MsgPtr], offset ScrollyMsg    ;set up pointer to message    
  131.     mov    FS:[ParamPtr], offset StartParams
  132.     ret
  133. SetUpSprites    ENDP
  134.     
  135.     
  136.  
  137. WriteBack    PROC NEAR
  138.  
  139.     mov    ax, 0a000h
  140.     mov    es, ax
  141.     mov    bx, [APage]
  142.  
  143.     push    ds
  144.     mov    ax, [PicSeg]
  145.     mov    ds, ax
  146.     xor    si, si
  147.     xor    di, di    
  148.     add    di, bx            ;for when writing second page
  149.  
  150.     call    WaitRetrace
  151.     mov    ah, 0001b        ;plane 0
  152.     SetMask
  153.     mov    cx, (19200 / 4)        ;1/4 of full screen (dwords)
  154.     rep    movsd
  155.     
  156.     xor    di, di
  157.     add    di, bx            ;for when writing second page
  158.     mov    ah, 0010b        ;plane 1
  159.     SetMask
  160.     mov    cx, (19200 / 4)
  161.     rep    movsd
  162.     
  163.     xor    di, di
  164.     add    di, bx            ;for when writing second page
  165.     xor    si, si            ;si back to 0 too (ds to be altered)                
  166.     mov    ax, ds
  167.     add    ax, (38400 / 16)    ;increment ds (in paras)
  168.     mov    ds, ax
  169.     mov    ah, 0100b        ;plane 2
  170.     SetMask
  171.     mov    cx, (19200 / 4)
  172.     rep    movsd
  173.     
  174.     xor    di, di
  175.     add    di, bx            ;for when writing second page
  176.     mov    ah, 1000b        ;plane 3
  177.     SetMask
  178.     mov    cx, (19200 / 4)
  179.     rep    movsd
  180.     
  181.     pop    ds
  182.     ret
  183.  
  184. WriteBack    ENDP
  185.  
  186. ScrollOn    PROC NEAR
  187.     mov    bx, 242*80
  188.  
  189.  
  190.    scrlloop:
  191.     call    SetVGAOffset
  192.     PollSB
  193.     sub     bx, 160
  194.     jnz    scrlloop
  195.            
  196.     xor    bx, bx
  197.     call    SetVGAOffset        ;make sure at row 0
  198.     ret
  199. ScrollOn    ENDP
  200.  
  201. WriteLetters    PROC NEAR
  202.     ; write the letters into the off-screen VGA
  203.     push    ds
  204.     mov    ax, [AlphaSeg]
  205.     mov    ds, ax            ;ES already set up
  206.     xor    si, si
  207.     mov    di, (76800 / 4)        ;just after picture
  208.     PollSB                ;keep music going
  209.     mov    ah, 0001b        ;Plane 0
  210.     SetMask
  211.     mov    cx, (10240 / 4)        ;(32 * 32 * 40) / 4    
  212.     rep    movsd                
  213.  
  214.     mov    di, (76800 / 4)        ;just after picture
  215.     PollSB                ;keep music going
  216.     mov    ah, 0010b        ;Plane 1
  217.     SetMask
  218.     mov    cx, (10240 / 4)        ;(32 * 32 * 40) / 4    
  219.     rep    movsd                
  220.  
  221.     mov    di, (76800 / 4)        ;just after picture
  222.     PollSB                ;keep music going
  223.     mov    ah, 0100b        ;Plane 2
  224.     SetMask
  225.     mov    cx, (10240 / 4)        ;(32 * 32 * 40) / 4    
  226.     rep    movsd                
  227.  
  228.     mov    di, (76800 / 4)        ;just after picture
  229.     PollSB                ;keep music going
  230.     mov    ah, 1000b        ;Plane 3
  231.     SetMask
  232.     mov    cx, (10240 / 4)        ;(32 * 32 * 40) / 4    
  233.     rep    movsd
  234.     pop    ds                
  235.     ret
  236. WriteLetters    ENDP
  237.  
  238. CopyLetters    PROC NEAR
  239.     xor    bx, bx        
  240.     mov    cx, 11        ;11 letters    
  241.   cpyletloop:
  242.     push    cx
  243.     
  244.     cmp    bx, FS:[FarLeft]        ;left clip?
  245.     jne    notleft
  246.     call    ClippedWriteL                    
  247.     jmp    skip
  248.   notleft:    
  249.     cmp    bx, FS:[FarRight]
  250.     jne    notright
  251.     call    ClippedWriteR
  252.     jmp    skip 
  253.      ; Normal write if here
  254.   notright:
  255.     push    bx
  256.     mov    di, FS:[Letter[bx].CurrentPos]
  257.     add    di, FS:[APage]            ;adjust for active page
  258.     mov    si, FS:[Letter[bx].GFXPtr]
  259.     mov    bx, FS:[Letter[bx].MaskPtr]
  260.  
  261.       mov    ecx, 200000h        ;32 lines
  262.    cline:
  263.     mov    cx, fs:[bx]        ;get word from bx (masks for 2*2*4=16 pix)
  264.     
  265.     inc    bx        
  266.     inc    bx
  267.     mov    ah, cl            
  268.     SetMask
  269.     mov    al, ds:[si]
  270.     mov     es:[di], al    
  271.     inc    di
  272.     inc    si
  273.     mov    ah, cl            ;bottom part to go
  274.     shr    ax, 4
  275.     SetMask
  276.     mov     al, ds:[si]
  277.     mov     es:[di], al    
  278.     inc    di
  279.     inc    si
  280.  
  281.     mov    ah, ch            
  282.     SetMask
  283.     mov     al, ds:[si]
  284.     mov     es:[di], al    
  285.     inc    di
  286.     inc    si
  287.     mov    ah, ch            ;bottom part to go
  288.     shr    ax, 4
  289.     SetMask
  290.     mov     al, ds:[si]
  291.     mov     es:[di], al    
  292.     inc    di
  293.     inc    si
  294.  
  295.     mov    cx, fs:[bx]        ;get word from bx (masks for 2*2*4=16 pix)
  296.     
  297.     inc    bx        
  298.     inc    bx
  299.     mov    ah, cl            
  300.     SetMask
  301.     mov     al, ds:[si]
  302.     mov     es:[di], al    
  303.     inc    di
  304.     inc    si
  305.     mov    ah, cl            ;bottom part to go
  306.     shr    ax, 4
  307.     SetMask
  308.     mov     al, ds:[si]
  309.     mov     es:[di], al    
  310.     inc    di
  311.     inc    si
  312.  
  313.     mov    ah, ch            
  314.     SetMask
  315.     mov     al, ds:[si]
  316.     mov     es:[di], al    
  317.     inc    di
  318.     inc    si
  319.     mov    ah, ch            ;bottom part to go
  320.     shr    ax, 4
  321.     SetMask
  322.     mov     al, ds:[si]
  323.     mov     es:[di], al    
  324.     inc    di
  325.     inc    si
  326.         add    di, (80-8)
  327.     xor    cx, cx
  328.        sub    ecx, 10000h
  329.        jnz cline
  330.     
  331.     pop    bx
  332. skip:                    ;arrive here if from a clipped write
  333.     add    bx, 14            ;next letter
  334.     pop    cx
  335.     loop    cpyletloop
  336.  
  337.  
  338.        ret
  339. CopyLetters    ENDP
  340.  
  341. ClippedWriteR    PROC NEAR
  342.     push    bx
  343.  
  344.     cmp     FS:[Clip], 0
  345.     je    All_clipped        ;if clip = 0 then no writes to do
  346.  
  347.     mov    di, FS:[Letter[bx].CurrentPos]
  348.     add    di, FS:[APage]            ;adjust for active page
  349.     mov    si, FS:[Letter[bx].GFXPtr]
  350.     mov    bx, FS:[Letter[bx].MaskPtr]
  351.  
  352.  
  353.       mov    ecx, 200000h        ;32 lines
  354.    CRcline:
  355.     mov    cx, fs:[bx]        ;get word from bx (masks for 2*2*4=16 pix)
  356.     
  357.     inc    bx        
  358.     inc    bx
  359.                         
  360.     mov    ah, cl            
  361.     SetMask
  362.     mov    al, ds:[si]        ;no clip test - at least 1 write
  363.     mov     es:[di], al    
  364.     inc    di
  365.     inc    si
  366.     
  367.     cmp    FS:[Clip], 2        ;end of write?
  368.     jb    ClipItR1        ;if so, skip the write
  369.                     ;mask file already in sinc but SI/DI
  370.                     ;are not - cannot skip the rest
  371.     mov    ah, cl            ;bottom part to go
  372.     shr    ax, 4
  373.     SetMask
  374.     mov     al, ds:[si]
  375.     mov     es:[di], al    
  376. ClipItR1:
  377.     inc    di
  378.     inc    si
  379.  
  380.     cmp    FS:[Clip], 3        ;end of write?
  381.     jb    ClipItR2        ;if so, skip the write
  382.     mov    ah, ch            
  383.     SetMask
  384.     mov     al, ds:[si]
  385.     mov     es:[di], al    
  386. ClipItR2:
  387.     inc    di
  388.     inc    si
  389.  
  390.     cmp    FS:[Clip], 4        ;end of write?
  391.     jb    ClipItR3        ;if so, skip the write
  392.     mov    ah, ch            ;bottom part to go
  393.     shr    ax, 4
  394.     SetMask
  395.     mov     al, ds:[si]
  396.     mov     es:[di], al    
  397. ClipItR3:
  398.     inc    di
  399.     inc    si
  400.  
  401.     mov    cx, fs:[bx]        ;get word from bx (masks for 2*2*4=16 pix)
  402.     inc    bx        
  403.     inc    bx
  404.     
  405.     cmp    FS:[Clip], 5        ;end of write?
  406.     jb    ClipItR4        ;if so, skip the write
  407.     mov    ah, cl            
  408.     SetMask
  409.     mov     al, ds:[si]
  410.     mov     es:[di], al    
  411. ClipItR4:
  412.     inc    di
  413.     inc    si
  414.  
  415.     cmp    FS:[Clip], 6        ;end of write?
  416.     jb    ClipItR5        ;if so, skip the write
  417.     mov    ah, cl            ;bottom part to go
  418.     shr    ax, 4
  419.     SetMask
  420.     mov     al, ds:[si]
  421.     mov     es:[di], al    
  422. ClipItR5:
  423.     inc    di
  424.     inc    si
  425.  
  426.     cmp    FS:[Clip], 7        ;end of write?
  427.     jb    ClipItR6        ;if so, skip the write
  428.     mov    ah, ch            
  429.     SetMask
  430.     mov     al, ds:[si]
  431.     mov     es:[di], al    
  432. ClipItR6:
  433.     inc    di
  434.     inc    si
  435.  
  436.     cmp    FS:[Clip], 8        ;end of write?
  437.     jb    ClipItR7        ;if so, skip the write
  438.     mov    ah, ch            ;bottom part to go
  439.     shr    ax, 4
  440.     SetMask
  441.     mov     al, ds:[si]
  442.     mov     es:[di], al    
  443. ClipItR7:
  444.     inc    di
  445.     inc    si
  446.         add    di, (80-8)
  447.     xor    cx, cx
  448.        sub    ecx, 10000h
  449.        jnz CRcline
  450. All_clipped:
  451.     pop    bx            ;get bx back here (avoid corrupting
  452.                     ;stack)
  453.     ret
  454. ClippedWriteR ENDP
  455.  
  456. ClippedWriteL    PROC NEAR
  457.     push    bx
  458.  
  459.     cmp     FS:[Clip], 7
  460.     jae    All_clipped2        ;if clip = 7 or 8 then no writes to do
  461.                     ;opposite to right clip, and also left
  462.                     ;sprite is offscreen for 2 frames
  463.                     
  464.     mov    di, FS:[Letter[bx].CurrentPos]
  465.     add    di, FS:[APage]            ;adjust for active page
  466.     mov    si, FS:[Letter[bx].GFXPtr]
  467.     mov    bx, FS:[Letter[bx].MaskPtr]
  468.  
  469.  
  470.       mov    ecx, 200000h        ;32 lines
  471.    CLcline:
  472.     mov    cx, fs:[bx]        ;get word from bx (masks for 2*2*4=16 pix)
  473.     
  474.     inc    bx        
  475.     inc    bx
  476.     
  477.     cmp    FS:[Clip], 0                    
  478.     ja    ClipItL0
  479.     mov    ah, cl            
  480.     SetMask
  481.     mov    al, ds:[si]        
  482.     mov     es:[di], al    
  483. ClipItL0:
  484.     inc    di
  485.     inc    si
  486.     
  487.     cmp    FS:[Clip], 1        ;start of write?
  488.     ja    ClipItL1        ;if not, skip the write
  489.                     ;mask file already in sinc but SI/DI
  490.                     ;are not - cannot skip the start
  491.     mov    ah, cl            ;bottom part to go
  492.     shr    ax, 4
  493.     SetMask
  494.     mov     al, ds:[si]
  495.     mov     es:[di], al    
  496. ClipItL1:
  497.     inc    di
  498.     inc    si
  499.  
  500.     cmp    FS:[Clip], 2        ;start of write?
  501.     ja    ClipItL2        ;if not, skip the write
  502.     mov    ah, ch            
  503.     SetMask
  504.     mov     al, ds:[si]
  505.     mov     es:[di], al    
  506. ClipItL2:
  507.     inc    di
  508.     inc    si
  509.  
  510.     cmp    FS:[Clip], 3        ;start of write?
  511.     ja    ClipItL3        ;if not, skip the write
  512.     mov    ah, ch            ;bottom part to go
  513.     shr    ax, 4
  514.     SetMask
  515.     mov     al, ds:[si]
  516.     mov     es:[di], al    
  517. ClipItL3:
  518.     inc    di
  519.     inc    si
  520.  
  521.     mov    cx, fs:[bx]        ;get word from bx (masks for 2*2*4=16 pix)
  522.     inc    bx        
  523.     inc    bx
  524.     
  525.     cmp    FS:[Clip], 4        ;start of write?
  526.     ja    ClipItL4        ;if not, skip the write
  527.     mov    ah, cl            
  528.     SetMask
  529.     mov     al, ds:[si]
  530.     mov     es:[di], al    
  531. ClipItL4:
  532.     inc    di
  533.     inc    si
  534.  
  535.     cmp    FS:[Clip], 5        ;start of write?
  536.     ja    ClipItL5        ;if not, skip the write
  537.     mov    ah, cl            ;bottom part to go
  538.     shr    ax, 4
  539.     SetMask
  540.     mov     al, ds:[si]
  541.     mov     es:[di], al    
  542. ClipItL5:
  543.     inc    di
  544.     inc    si
  545.  
  546.     cmp    FS:[Clip], 6        ;start of write?
  547.     ja    ClipItL6        ;if not, skip the write
  548.     mov    ah, ch            
  549.     SetMask
  550.     mov     al, ds:[si]
  551.     mov     es:[di], al    
  552. ClipItL6:
  553.     inc    di
  554.     inc    si
  555.  
  556.     mov    ah, ch            ;bottom part to go
  557.     shr    ax, 4
  558.     SetMask                ;no test - if in the loop there must
  559.     mov     al, ds:[si]        ;be at least 1 write
  560.     mov     es:[di], al    
  561.     inc    di
  562.     inc    si
  563.         add    di, (80-8)
  564.     xor    cx, cx
  565.        sub    ecx, 10000h
  566.        jnz CLcline
  567. All_clipped2:
  568.     pop    bx            ;get bx back here (avoid corrupting
  569.                     ;stack)
  570.     ret
  571. ClippedWriteL ENDP
  572.     
  573. CopyBack    PROC NEAR
  574.     xor    bx, bx
  575.     mov    ecx, 0b0000h        ;11 sprites
  576.     mov    di, (19200 + 10240)    ;base address of first background
  577.     mov    ah, 1111b
  578.     SetMask
  579. cpyloop:    
  580.     mov    si, FS:[Letter[bx].OldPos]
  581.     add    si, FS:[APage]        
  582.     mov    cx, 32
  583.   cpyline:    
  584.     mov    al, ds:[si]
  585.     mov     es:[di], al    
  586.     inc    di
  587.     inc    si
  588.     mov     al, ds:[si]
  589.     mov     es:[di], al    
  590.     inc    di
  591.     inc    si
  592.     mov     al, ds:[si]
  593.     mov     es:[di], al    
  594.     inc    di
  595.     inc    si
  596.     mov     al, ds:[si]
  597.     mov     es:[di], al    
  598.     inc    di
  599.     inc    si
  600.     mov     al, ds:[si]
  601.     mov     es:[di], al    
  602.     inc    di
  603.     inc    si
  604.     mov     al, ds:[si]
  605.     mov     es:[di], al    
  606.     inc    di
  607.     inc    si
  608.     mov     al, ds:[si]
  609.     mov     es:[di], al    
  610.     inc    di
  611.     inc    si
  612.     mov     al, ds:[si]
  613.     mov     es:[di], al    
  614.     inc    di
  615.     inc    si
  616.     add    si, (80 - 8)
  617.     loop    cpyline
  618.     
  619.     add    bx, 14
  620.     sub    ecx, 10000h
  621.     jnz    cpyloop
  622.     
  623.  
  624.     ret
  625. CopyBack    ENDP    
  626.  
  627. RestoreBack    PROC NEAR
  628.     xor    bx, bx
  629.     mov    ecx, 0b0000h        ;11 sprites
  630.     mov    si, (19200 + 10240)    ;base address of first background
  631.     mov    ah, 1111b
  632.     SetMask
  633. resloop:    
  634.     mov    di, FS:[Letter[bx].OldPos]
  635.     add    di, FS:[APage]        ;adjust for active page
  636.     mov    cx, 32
  637.   rline:    
  638.     mov     al, ds:[si]        ;unravelled for *speeeeeed* 8-)
  639.     mov     es:[di], al        ;movsb is sloooow (can't use movsw
  640.     inc    di            ;or above because of latches - theres
  641.     inc    si            ;only 1 per plane
  642.     mov     al, ds:[si]
  643.     mov     es:[di], al    
  644.     inc    di
  645.     inc    si
  646.     mov     al, ds:[si]
  647.     mov     es:[di], al    
  648.     inc    di
  649.     inc    si
  650.     mov     al, ds:[si]
  651.     mov     es:[di], al    
  652.     inc    di
  653.     inc    si
  654.     mov     al, ds:[si]
  655.     mov     es:[di], al    
  656.     inc    di
  657.     inc    si
  658.     mov     al, ds:[si]
  659.     mov     es:[di], al    
  660.     inc    di
  661.     inc    si
  662.     mov     al, ds:[si]
  663.     mov     es:[di], al    
  664.     inc    di
  665.     inc    si
  666.     mov     al, ds:[si]
  667.     mov     es:[di], al    
  668.     inc    di
  669.     inc    si
  670.     add    di, (80 - 8)
  671.     loop    rline
  672.     
  673.     add    bx, 14
  674.     sub    ecx, 10000h
  675.     jnz    resloop
  676.     
  677.  
  678.     ret
  679. RestoreBack    ENDP        
  680.  
  681. CalcPositions    PROC NEAR
  682.  
  683.     cmp    FS:[DelayCount], 0
  684.     je    PauseOff
  685.     dec    FS:[DelayCount]
  686.     jmp    Cont
  687. PauseOff:
  688.     mov    FS:[Paused], 0
  689. Cont:
  690.  
  691.     xor    bx, bx
  692.     mov    cx, 11
  693.   posloop:
  694.     xor    eax, eax
  695.     mov    ax, FS:[Letter[bx].CurrentPos]    ;get pos before adjustment
  696.     mov    FS:[Letter[bx].OldPos], ax    ;and save it
  697.  
  698.     cmp    FS:[Paused], 1
  699.     je    NoXDec
  700.       dec    FS:[Letter[bx].XPos]     
  701. NoXDec:
  702.     mov    ax, FS:[Letter[bx].CurrentY]
  703.     add    ax, Gravity
  704.     mov    FS:[Letter[bx].CurrentY], ax
  705.     add    FS:[Letter[bx].YPos], ax
  706.     mov    ax, FS:[Letter[bx].YPos]
  707.     cmp    ax, Floor
  708.     jb    NoBounce
  709.     mov    ax, Floor - 1
  710.     mov    FS:[Letter[bx].YPos], ax
  711.     not    FS:[Letter[bx].CurrentY]    ;reverse direction, less 1
  712.   NoBounce:
  713.     
  714.     FASTIMUL edx, eax, 240            ;mult by 240 
  715.     shr    edx, 9                ;div by 512
  716.     FASTIMUL ax, dx, 80            ;mult by X Dimension
  717.     add    ax, FS:[Letter[bx].XPos]        
  718.     sub    ax, 40                ;adjust for X offset
  719.     mov    FS:[Letter[bx].CurrentPos], ax    ;save calc'd position
  720.     
  721.     add    bx, 14                ;next element            
  722.     loop    posloop
  723.     
  724.  
  725.     ret
  726. CalcPositions    ENDP
  727.     
  728.  
  729. ReadLetter    PROC NEAR
  730.     mov    bx, FS:[MsgPtr]
  731.     xor    ax, ax
  732.     mov    al, FS:[bx]        ;get next letter
  733.     
  734.     cmp    al, 94            ;"^" sign
  735.     jne    NoSmallPause
  736.     mov    FS:[DelayCount], 100    ;set up pause in message
  737.     inc    FS:[MsgPtr]        ;increment pointer
  738.     inc    bx            ;increase bx for immediate effect
  739.     mov    al, FS:[bx]        ;get next letter in advance for when
  740.                     ; letters start moving again    
  741.     mov    FS:[Paused], 1        ;Pause on
  742.     mov    FS:[Clip], 0        ;set clip correctly
  743.     jmp    NoPause
  744. NoSmallPause:
  745.     cmp    al, 38            ;"&" sign
  746.     jne    NoPause
  747.     mov    FS:[DelayCount], 300    ;set up pause in message
  748.     inc    FS:[MsgPtr]        ;increment pointer
  749.     inc    bx            ;increase bx for immediate effect
  750.     mov    al, FS:[bx]        ;get next letter in advance for when
  751.                     ; letters start moving again    
  752.     mov    FS:[Paused], 1        ;Pause on
  753.     mov    FS:[Clip], 0        ;set clip correctly
  754.  
  755.  
  756. NoPause:
  757.     cmp    al, 36            ;"$" sign
  758.     jne    NoWrap
  759.      mov    bx, offset ScrollyMsg    ;reset message pointer
  760.      mov    FS:[MsgPtr], bx
  761.      mov    al, FS:[bx]
  762.  NoWrap:
  763.     inc    FS:[MsgPtr]
  764.     cmp    al, 32            ;[space]
  765.     jne    notspace
  766.     mov    bx, FS:[FarRight]        
  767.     mov    FS:[Letter[bx].MaskPtr], offset DummyMask
  768.                        ;put blank mask (GFX doesn't matter)
  769.     ret
  770. notspace:
  771.     cmp    al, 57            ;'9'
  772.     ja    alpha            ;goto A-Z (inc ?)    
  773.     cmp    al, 48            ;'0'
  774.     jb    cntrl            ;goto extra characters
  775.  
  776.  
  777.                 ;if here, must be numeric
  778.     sub    ax, 22            ; sub 48 ('0'), add 26 (start of nos)
  779.     jmp    assignGFX
  780. cntrl:
  781.     cmp    al, '!'
  782.     jne    not_shriek
  783.     mov    ax, 36            
  784.     jmp    assignGFX
  785.   not_shriek:
  786.     cmp    al, '.'
  787.     jne    not_stop
  788.     mov    ax, 38
  789.     jmp    assignGFX
  790.   not_stop:
  791.     cmp    al, 39            ; " ' "
  792.     jne    not_apos
  793.     mov    ax, 39            
  794.     jmp    assignGFX
  795.   not_apos:
  796.                     ;*invalid character*
  797.     mov    bx, FS:[FarRight]        
  798.     mov    FS:[Letter[bx].MaskPtr], offset DummyMask
  799.                        ;put blank mask (GFX doesn't matter)
  800.     ret
  801.         
  802. alpha:
  803.  
  804.     cmp    al, '?'
  805.     jne    not_q
  806.     mov    ax, 37            
  807.     jmp    assignGFX
  808.   not_q:
  809.  
  810.     sub    ax, 65            ;all alphabetic characters
  811. assignGFX:
  812.  
  813.     mov    dx, ax            ;save letter value
  814.     shl    ax, 8            ;mult by 1024 (32*8) - size of GFX
  815.     add    ax, 19200        ;base offset of letter graphics
  816.     mov    bx, FS:[FarRight]        
  817.     mov    FS:[Letter[bx].GFXPtr], ax  ;put letter in far right
  818.     shl    dx, 7            ;mult by 128 (32*32/8)- size of mask
  819.     mov    ax, offset BitMask    ;base offset
  820.     add    ax, dx            ;add positioning
  821.     mov    FS:[Letter[bx].MaskPtr], ax  ;put mask in far right
  822.     ret
  823. ReadLetter    ENDP
  824.  
  825. CheckLetters    PROC NEAR
  826.     mov    bx, FS:[FarLeft]
  827.     cmp    FS:[Letter[bx].XPos], 32 ;32-40 = -8 ie off screen (8*4 = 32)
  828.     ja    NoNewLetter
  829.     mov    FS:[FarRight], bx    ;Move this one over to Far Right
  830.  
  831.     mov    bx, FS:[ParamPtr]    ;get start parameters
  832.     mov    ax, FS:[bx]        ;get CurrentY (or end marker)
  833.     cmp    ax, 999            ;end of list?
  834.     jne    NotEndParams
  835.     mov    bx, offset StartParams
  836.     mov    FS:[ParamPtr], bx    ;reset ptr
  837.     mov    ax, FS:[bx]        ;get next one
  838. NotEndParams:
  839.     add    FS:[ParamPtr], 4    ;increment ptr (2 words)
  840.     add    bx, 2
  841.     mov    dx, FS:[bx]        ;get YPos
  842.     
  843.     mov    bx, FS:[FarRight]    ;get bx back
  844.     mov    FS:[Letter[bx].XPos], 120  ;set max X (offscreen)
  845.     mov    FS:[Letter[bx].YPos], dx   ;set YPos
  846.     mov    FS:[Letter[bx].CurrentY], ax  ;set CurrentY
  847.     add    bx, 14            ;FarLeft = next one right
  848.     cmp    bx, (10 * 14)
  849.     jna    ValidBX
  850.     xor    bx, bx            ;Letter 0 if over 11th letter
  851. ValidBX:        
  852.     mov    FS:[FarLeft], bx    ;save new FarLeft
  853.     call    ReadLetter        ;get next letter from message
  854. NoNewLetter:    
  855.     ret
  856. CheckLetters    ENDP
  857.  
  858. FlipVisualPage    PROC NEAR
  859.     mov    bx, FS:[APage]
  860.     xor    bx, PAGE2        ;flip address 0/32320
  861.     mov    FS:[APage], bx
  862.     mov    bx, FS:[APage]
  863.     call    SetVGAOffset        ;set it (includes retrace)
  864.                     ;WHY DOES IT WORK THIS WAY AROUND???!
  865.     ret
  866. FlipVisualPage    ENDP    
  867.  
  868. FadeOut    PROC NEAR
  869.     mov    si, offset BPalette
  870.     mov    dx, DAC_INDEX
  871.     xor    ax, ax
  872.     out    dx, al        ;select colour 0
  873.     inc    dx        ;where we set RGB values    
  874.  
  875.     mov    cx, 768    
  876.   decloop1:    
  877.     xor    ax, ax
  878.     mov    al, FS:[si]
  879.     sub    ax, 2        ;word value as no byte penalty
  880.     jnc    StillOK2        ;if carry, has gone negative
  881.     xor    ax, ax
  882.   StillOk2:        
  883.     mov    FS:[si], al
  884.     out    dx, al         ;set the colour    
  885.     inc    si
  886.   loop decloop1
  887.       ret
  888. FadeOut    ENDP
  889.  
  890.  
  891. ; **************************** MAIN PART *****************************
  892. ScrollDemo    PROC NEAR
  893.     call    Set13h
  894.     mov    cx, 40            ;v-screen 320 pix across
  895.     call    SetModeX
  896.     call    BlackPal        ;Black out palette to save flicker
  897.     call    ClearModeX
  898.      call    Set320x240        ;set 320 x 240 mode
  899.  
  900.     call    BlackPal        ;just to make sure
  901.     
  902.     mov    bx, (240*80)
  903.     call    SetVGAOffset        ;position below main screen
  904.     
  905.     call    WriteBack
  906.     mov    si, offset BPalette
  907.     call    SetPal
  908.     call    ScrollOn
  909.     call    WaitRetrace        ;ensure offset has 'taken'
  910.     call    WriteLetters
  911.     xor    [APage], PAGE2        ;flip the page pointer
  912.     call    WriteBack        ;write in the second background
  913.     xor    [APage], PAGE2        ;flip pointer back
  914.     
  915.     push    ds
  916.     pop    fs            ;FS = DS
  917.     push    es
  918.     pop    ds            ;VGA seg ito DS
  919.  
  920.     mov    ah, 1
  921.     call    SetWriteMode        ;set WM1
  922.  
  923.     call    SetUpSprites
  924.     call    ReadLetter
  925.     call    CalcPositions        ;initial set ups
  926.     call    CopyBack
  927.   keepup:
  928.     cmp    FS:[DelayCount], 0
  929.     jne    StillPaused            ;if stationary, no change in clip
  930.     and    FS:[Clip], 7
  931.     inc    FS:[Clip]    
  932. StillPaused:                        
  933.     call    FlipVisualPage
  934.         
  935.     call    RestoreBack
  936.     call    CalcPositions
  937.     call    CopyBack
  938.     call    CopyLetters
  939.     PollSB
  940.     call    CheckLetters
  941.  
  942.     
  943.     mov    ah, 1
  944.     int    16h
  945.     jz    keepup
  946.     
  947.     
  948.     mov    ah, 0
  949.     int    16h            ;discard keystroke
  950.  
  951.     mov    cx, 50
  952.   fadeloop2:
  953.     push    cx
  954.     cmp    FS:[DelayCount], 0
  955.     jne    StillPaused2            ;if stationary, no change in clip
  956.     and    FS:[Clip], 7
  957.     inc    FS:[Clip]    
  958. StillPaused2:                        
  959.     call    FlipVisualPage
  960.         
  961.     call    RestoreBack
  962.     call    CalcPositions
  963.     call    CopyBack
  964.     call    CopyLetters
  965.     PollSB
  966.     call    CheckLetters
  967.     
  968.     call    FadeOut
  969.     
  970.     pop    cx
  971.     loop    fadeloop2
  972.     
  973.                     
  974.     push    fs
  975.     pop    ds
  976.     
  977.     
  978.     ret
  979. ScrollDemo    ENDP